package com.itheima.order.controller;

import com.itheima.order.pojo.Order;
import com.itheima.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    OrderService orderService;

    /**
     * 根据用户名查询订单列表
     * @param username
     * @return
     */
    @GetMapping("/{username}")
    public List<Order> findOrdersByUserName(@PathVariable("username") String username){


        //int a = 1/0;
        List<Order> orders = orderService.findOrdersByUserName(username);
        return orders;
    }
}
